<!--
 * @Author: liuyonghu
 * @Date: 2021-08-18 12:21:16
 * @LastEditTime: 2021-08-30 23:43:51
 * @LastEditors: liuyonghu
 * @Description: 
 * @FilePath: /demos/socket.html
-->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="https://cdn.bootcdn.net/ajax/libs/socket.io/4.1.3/socket.io.min.js"></script>

    <script>
      // const ws = new WebSocket("http://127.0.0.1:3000");
        // const ws = new WebSocket("ws://127.0.0.1:4100/socket.io/?EIO=4&transport=websocket&sid=jtb8k85vohX8p3TtAAAe");
/^(?:(?:\+|00)86)?1[3-9]\d{9}$/
        // ws.onopen = function () {
        //   // Web Socket 已连接上，使用 send() 方法发送数据
        //   // ws.send("监听频道");
        //   alert("数据发送中...");
        // };

        // ws.onmessage = function (evt) {
        //   var received_msg = evt.data;
        //   alert("数据已接收...");
        // };

        // ws.onclose = function () {
        //   // 关闭 websocket
        //   alert("连接已关闭...");
        // };

      const ws = io("ws://127.0.0.1:4100");
      ws.emit("监听频道");
     
      ws.on("connect", (socket) => {
        console.log(" - connection - ");
      });
    </script>
  </body>
</html>
